package controllers;

import model.IMaster;
import model.IOrder;

//import java.util.TreeSet;;
public class SortController {

	public void sortOrderByFillingDate(IOrder[] orders) {

		for (int i = 0; i < orders.length; i++) {
			for (int j = 0; j < orders.length; j++) {
				if (orders[j].getFilingDate().before(orders[i].getFilingDate())) {
					IOrder tempOrder = orders[j];
					orders[j] = orders[i];
					orders[i] = tempOrder;
				}
			}
		}
	}

	public void sortByPerfomanceDate(IOrder[] orders) {

		for (int i = 0; i < orders.length; i++) {
			for (int j = 0; j < orders.length; j++) {
				if (orders[j].getPerfomanceDate().before(orders[i].getPerfomanceDate())) {
					IOrder tempOrder = orders[j];
					orders[j] = orders[i];
					orders[i] = tempOrder;
				}
			}
		}
	}

	public void sortByPlannedStartDate(IOrder[] orders) {

		for (int i = 0; i < orders.length; i++) {
			for (int j = 0; j < orders.length; j++) {
				if (orders[j].getPlannedStartDate().before(
						orders[i].getPlannedStartDate())) {
					IOrder tempOrder = orders[j];
					orders[j] = orders[i];
					orders[i] = tempOrder;
				}
			}
		}
	}

	public void sortByPrice(IOrder[] orders) {

		for (int i = 0; i < orders.length; i++) {
			for (int j = 0; j < orders.length; j++) {
				if (orders[j].getPrice() < (orders[i].getPrice())) {
					IOrder tempOrder = orders[j];
					orders[j] = orders[i];
					orders[i] = tempOrder;
				}
			}
		}
	}

	public void sortByName(IMaster[] masters) {
		for (int i = 0; i < masters.length; i++) {
			for (int j = 0; j < masters.length; j++) {

				int result = masters[i].getNameMaster().compareTo(
						masters[j].getNameMaster());
				if (result != 0) {

				}
			}
		}
	}
	
	public void sortByEmployment(IMaster[] masters){
		for (int i = 0; i < masters.length; i++) {
			for (int j = 0; j < masters.length; j++) {
				if (masters[j].getEmploymentMaster()){
					IMaster tempMast=masters[j];
					masters[i]=masters[j];
					masters[j]=tempMast;
				}
			}
			}
		
	}
}
